package com.yueke.gemini.controller;

import com.yueke.gemini.common.ApiResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 *  解析excel
 */
@RequestMapping("/excel")
public interface IExcelController {


    /**
     * 上传
     *
     * @param file
     * @return
     * @throws IOException
     */
    @RequestMapping(value = "/upload",method = RequestMethod.POST)
    @ResponseBody
    public ApiResult<String> upload(MultipartFile file) throws IOException;

    /**
     * 读取 Excel（允许多个 sheet）
     *
     * @param excel
     * @return
     */
    @RequestMapping(value = "readExcelWithSheets", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult<Object> readExcelWithSheets(MultipartFile excel);

    /**
     * 读取 Excel（指定某个 sheet）
     */
    @RequestMapping(value = "readExcel", method = RequestMethod.POST)
    @ResponseBody
    public ApiResult<Object> readExcel(MultipartFile excel, int sheetNo,
                                       @RequestParam(defaultValue = "1") int headLineNum);


    /**
     * 导出 Excel（一个 sheet）
     */
    @RequestMapping(value = "writeExcel", method = RequestMethod.GET)
    @ResponseBody
    public void writeExcel(HttpServletResponse response) throws IOException;


    /**
     * 导出 Excel（多个 sheet）
     */
    @RequestMapping(value = "writeExcelWithSheets", method = RequestMethod.GET)
    @ResponseBody
    public void writeExcelWithSheets(HttpServletResponse response) throws IOException;

}
